<%@ page contentType="text/html;charset=UTF-8" %>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>
<%
String path = request.getContextPath();
String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
%>
<c:set var="jpath" value="${pageContext.request.contextPath }"/>
<!DOCTYPE html>
<html lang="en">
	<head>
		<meta charset="utf-8" />
		<title>Bootstrap表单组件 - Bootstrap后台管理系统模版Ace下载</title>
		<meta name="keywords" content="Bootstrap模版,Bootstrap模版下载,Bootstrap教程,Bootstrap中文" />
		<meta name="description" content="站长素材提供Bootstrap模版,Bootstrap教程,Bootstrap中文翻译等相关Bootstrap插件下载" />
		<meta name="viewport" content="width=device-width, initial-scale=1.0" />
		<%@include file="css.jsp"%>
		<link rel="stylesheet" href="${jpath}/static/plugins/zTree/css/zTreeStyle/zTreeStyle.css" />
		<style type="text/css">
			.ztree * {font-size: 10pt;font-family:"Microsoft Yahei",Verdana,Simsun,"Segoe UI Web Light","Segoe UI Light","Segoe UI Web Regular","Segoe UI","Segoe UI Symbol","Helvetica Neue",Arial}
			.ztree li ul{ margin:0; padding:0}
			.ztree li {line-height:30px;}
			.ztree li a {width:70px;height:30px;padding-top: 0px;}
			.ztree li a:hover {text-decoration:none; background-color: #E7E7E7;}
			.ztree li a span.button.switch {visibility:hidden}
			.ztree.showIcon li a span.button.switch {visibility:visible}
			.ztree li a.curSelectedNode {background-color:#D4D4D4;border:0;height:30px;}
			.ztree li span {line-height:30px;}
			.ztree li span.button {margin-top: -7px;}
			.ztree li span.button.switch {width: 16px;height: 16px;}
			
			.ztree li a.level0 span {font-size: 100%;font-weight: bold;}
			.ztree li span.button {background-image:url("${jpath}/static/plugins/zTree/demo/cn/super/left_menuForOutLook.png"); *background-image:url("${jpath}/static/plugins/zTree/demo/cn/super/left_menuForOutLook.gif")}
			.ztree li span.button.switch.level0 {width: 20px; height:20px}
			.ztree li span.button.switch.level1 {width: 20px; height:20px}
			.ztree li span.button.noline_open {background-position: 0 0;}
			.ztree li span.button.noline_close {background-position: -18px 0;}
			.ztree li span.button.noline_open.level0 {background-position: 0 -18px;}
			.ztree li span.button.noline_close.level0 {background-position: -18px -18px;}
			.modal-footer{background:none !important;border:none !important;}
		</style>
	</head>

	<body>
<div class="page-content">
		<div class="page-header">
			<h1>
				Tables
				<small>
					<i class="icon-double-angle-right"></i>
					Static &amp; Dynamic Tables
				</small>
			</h1>
		</div><!-- /.page-header -->
		<div class="row">
			<div class="col-xs-4">
				<div class="row">
					<ul id="treeDemo" class="ztree"></ul>
				</div>
			</div>
			<div class="col-xs-8"><div class="col-xs-12">
				<!-- PAGE CONTENT BEGINS -->
				<div class="row">
					<div class="col-xs-12">
						<div class="table-responsive">
							<table id="sample-table-1" class="table table-striped table-bordered table-hover">
								<thead>
									<tr>
										<th class="center">
											<label>
												<input id="ch" type="checkbox" class="ace" value="全选" />
												<span class="lbl"></span>
											</label>
										</th>
										<th>标题</th>
										<th>发布时间</th>

										<th>发布人</th>

										<th>新闻内容</th>

										<th>新闻栏目名称</th>

										<th>浏览数量</th>
										<th>操作</th>
									</tr>
								</thead>

								<tbody>
									
								</tbody>
							</table>
						</div><!-- /.table-responsive -->
					</div><!-- /span -->
				</div><!-- /row -->
			</div><!-- /.col --></div>
			
		</div><!-- /.row -->
		<div id="xuhaoRong" class="modal-footer no-margin-top">
			<button class="btn btn-app btn-danger btn-sm" style="float: left;"  onClick=delMBtn(0);>
				<i class="icon-trash bigger-200"></i>
				批量删除
			</button>
	
			<button class="btn btn-app btn-purple btn-sm"  style="float: left;"  onClick=insertBtn(0); >
				<i class="icon-cloud-upload bigger-200"></i>
				添加
			</button>
			<ul id="xuhao" class="pagination pull-right no-margin" style="padding-top: 45px;">
			</ul>
		</div>
							

	</div><!-- /.page-content -->
<%@include file="js.jsp"%>
<script src='${jpath}/static/plugins/zTree/js/jquery.ztree.all.min.js'></script>
<script type="text/javascript">
	var colM=[{
		name:'id',
		cl:function(index,val){
			return '<label><input type="checkbox" name="check" class="ace" value="'+val+'"/><span class="lbl"><input type="hidden"></span></label>';
			}
		},{
			name:'title'
		},{
			name:'releaseTimeToString'
		},{
			name:'publisher'
		},{
			name:'newsContent',
			cl:function(index,val){
				return val.substring(0,8) +'....';
			}
		},{
			name:'columnName'
		},{
			name:'browsingCount'
		},{
			name:'id',
			cl:function(index,val){
				return '<div class="btn-group"><button class="btn btn-xs btn-info" onclick="updateBtn(\''+val+'\')"><i class="icon-edit bigger-120"></i></button><button class="btn btn-xs btn-danger" onclick="delBtn(\''+val+'\')"><i class="icon-trash bigger-120"></i></button></div>';
			}
		}];
	var pasrams={pageNum:1,pageSize:2};	
	var setting = {
			async: {
				enable: true,
				url:"${jpath}/newsColumn/findAllUI",
				autoParam:["id", "name=n", "level=lv"],
				otherParam:{"otherParam":"zTreeAsyncTest"},
				dataFilter: filter
			},
			data:{
				key:{
					name:"columnName"
				},
				simpleData:{
					
				}
			},
			callback: {
				onClick: zTreeOnClick
			}
		};
	function filter(treeId, parentNode, childNodes) {
		return childNodes.obj;
	}
	function zTreeOnClick(event, treeId, treeNode) {
		console.log(treeNode.id);
		var params={pageNum:1,pageSize:2};	
		$("#sample-table-1").loadTbl(colM,params,"${jpath}/information/showInfo?columnNumber="+treeNode.id,false);
		
	};
	function delMBtn(id){
		var delId=new Array();
		$("input[type='checkbox']").each(function(index) {
			if ($(this).is(':checked') == true) {
		  		delId[index] = $(this).val(); 
			} 
		});
		var str = delId.toString();
		$.post("${jpath}/information/deleteBatch",{uiCheck:str},function(data){
				var json = $.parseJSON(data);
				alert(json.resMsg);
				if(json.resMsg=="批量删除成功"){
					var hrefStr = "${jpath}/newsColumnContent";
					location.href=hrefStr;
				};
			}
		);
	};
	function delBtn(id){
		$.post("${jpath}/information/delect",{id:id},
			function(data){
				var json = $.parseJSON(data);
				alert(json.resMsg);
				if(json.resMsg=="删除成功"){
					var hrefStr = "${jpath}/informationContent";
					location.href=hrefStr;
				};
			}
		);
	};
	function updateBtn(id){
		var hrefStr = "${jpath}/information/informationInfo?id="+id;
		location.href=hrefStr;
	};
	function insertBtn(id){
		var hrefStr = "${jpath}/information/informationInfo?id="+id;
		location.href=hrefStr;
	};
	$(function(){
		$.fn.zTree.init($("#treeDemo"), setting);
		$("#sample-table-1").loadTbl(colM,pasrams,"${jpath}/information/findByPage",true);
		 $("#ch").click(function(){
          //转化为JQ对象并调用prop方法获取属性
          //alert($(this).prop("checked"));
               //获取其他复选框，使用prop方式设置属性与全选框保持一致
         	 $("input[type='checkbox']").prop("checked",$(this).prop("checked"));  
          });
	});
</script>
</body>
</html>
